{% extends 'siteAdmin/index.html' %}

{% block operation %}

{% if req.path ==pageData['subdomain']|nonone +'/siteAdmin/newsAdd' %}
<div id="box">
    <span class="testa"><h3>Aggiungi una News</h3></span><br />
        {% if pageData['news'].id %}
            <form  method="POST" action="/siteAdmin/newsAdd?update={{pageData['news'].id}}">
        {% else %}
            <form  method="POST" action="/siteAdmin/newsAdd?add">
        {% endif %}
                <span class="word">titolo</span>
                <span class="insert">
                <input name="newsTitle" type="text" value ="{{pageData['news'].title|nonone}}" style="width: 75%"/></span><br /><br />
                <span class="word">Abstract</span>
                <span style="text-align:center;"><textarea name="newsAbstract" type="text" rows="5"  style="width: 75%;">{{pageData['news'].abstract|nonone}}</textarea></span><br />
                <span class="word">corpo</span>
                <textarea name="newsBody" rows="20"  style="width: 75%">{{pageData['news'].body|nonone}}</textarea><br />
                <div class="row thin lineTop">
                <span class="word">Seleziona la categoria News:</span>
                        <select name="categoriaId">
                    {% for cate in pageData['newsCategory'] %}
                    <option value="{{cate.id}}">{{cate.denominazione}}</option>
                    {% endfor %}
                    </select>
                    </div>
                            <div class="row thin lineTop">
                <span class="word">Seleziona la lingua predefinita:</span>
                    <select name="languageId">
                    {% for lang in pageData['language'] %}
                    <option value="{{lang.id}}">{{lang.denominazione}}</option>
                    {% endfor %}
                    </select>
                    </div>
                <span class="word">Url Fonte notizia ( con http:// ) </span>
                <span class="insert">
                <input name="newsSourceUrl" type="text" value ="{{pageData['news'].source_url|nonone}}" style="width: 100%"/></span><br />
                <span class="word">Url Fonte Testo alternativo notizia</span>
                <span class="insert">
                <input name="newsSourceUrlAltText" type="text" value ="{{pageData['news'].source_url_alt_text|nonone}}" style="width: 100%"/></span><br />
           <br />
                <div style="height:110px;">
                <img src="/templates/news_img/{{pageData['news'].imagepath}}.jpg?{{pageData['now']}}" alt="{{pageData['news'].title}}" class="img_left" /><br /><br />
                <a HREF="/siteAdmin/fileupload?id={{pageData['news'].id}}&amp;part=newsAdd"
                    onClick="return targetopener(this)">Aggiungi o modifica la foto abbinata</a></div>
            <br /><br />
                <input type="submit" class="wymupdate" value="Aggiungi/modifica"/></form>
                <p>PERMALINK:<a href="/promoGest/news_detail/{{pageData['news'].permalink}}">{{pageData['news'].permalink}}</a></p>
        </div>

    {% elif req.path =='/siteAdmin/newsList' %}
        <div id="box">
                <span class="testa"><h1>Gestione News</h1></span>

    {% include 'common/searchBox.html' with context %}

                <div class="row normal">
                <a href="/siteAdmin/newsAdd?new">
                    <img src="/templates/siteAdmin/img/add.png" alt="aggiungi una News" title="aggiungi una News"/>
                </a>
                </div>
                {% for page in pageData['news'] %}
                <div class="row normal lineTop" >

                    <span ><b>{{page.publication_date|dateformat}}</b> - <a href="/promoGest/news_detail/{{page.permalink}}">{{page.permalink}}</a> - ({{page.lang.denominazione_breve}}) </span>
                    <span class="image"><a href="/siteAdmin/newsDel?newsId={{page.id}}" onClick='return confirm("Sei sicuro di voler cancellare questa news?")' ><img src="/templates/siteAdmin/img/trash.png" alt="elimina la news" title="elimina la news"/></a></span>
                    <span class="image"><a href="/siteAdmin/newsAdd?edit={{page.id}}"><img src="/templates/siteAdmin/img/modifica.png" alt="modifica una news" title="modifica una news"/></a></span>
            {% if page.active==1 %}
            <span class="image normal" >
                <a href="/siteAdmin/newsActive?id={{page.id}}&amp;pag={{pageData['args']['pag']+1}}">
                    <img src="/templates/siteAdmin/img/active_on.png" alt="disattiva News" title="disattiva News"/>
                </a>
            </span>
            {% endif%}
            {% if page.active==0 %}
            <span class="image normal">
                <a href="/siteAdmin/newsActive?id={{page.id}}&amp;pag={{pageData['args']['pag']+1}}">
                    <img src="/templates/siteAdmin/img/active_off.png" alt="attiva News" title="attiva News"/>
                </a>
            </span>
            {% endif%}
                </div>
                {% endfor %}
        {% include 'common/pagination.html' with context %}
                <div class="row normal lineTop">
                <a href="/siteAdmin/newsAdd?new">
                    <img src="/templates/siteAdmin/img/add.png" alt="aggiungi una pagina" title="aggiungi una pagina"/>
                </a>
                </div>
        </div>

{% endif %}
        </div>
{%endblock%}
